/**
 * @author admin
 * 35. 搜索插入位置
 * //解法：（题目要求时间复杂度为O（logn）二分查找算法，
 */
public class LeeCode35 {

    public static void main(String[] args) {

        int []nums = new int[]{1,2,4,5};
        int target = 3;
        int left = 0;
        int n = nums.length;
        int right = n - 1;
        while (left < right){
            int mid = left + (right - left)/2;
            if(nums[mid] <= target){
                left = mid + 1;
            }else {
                right = mid - 1;
            }
        }
        System.out.println(left);

    }
}
